home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Communications / General / LineShare Folder / Put Onto Productions Disks / LineShare Scripts / Prometheus Home Office Fax&ARA < prev    next >
Text File  |  1993-12-08  |  6KB  |  263 lines

  1. ! Version 1.0
  2. !
  3. !$ Use this script with Sierra-based (Prometheus, etc) 2400/9600 fax modems.
  4. !$ Supports fax and ARA incoming calls.
  5. !$ Make sure that Class 2 fax software is installed
  6. !
  7. !$ A cable for hardware handshaking is required
  8.  
  9. ^2 Speaker On:        = Enum("Never" = "0","During Connect" = "1", "Always"="2") "1"
  10. ^3 Speaker Volume:       = Enum("Low"="1","Medium"="2","High"="3") "2"
  11. ^4 Answer On:         = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  12. ^5 Fax Identifier:    = Text "Stalker_GmbH"
  13. ^6 Handshake wires:   = Bool("Both"="&D0\Q2","CTS only"="&D2\Q3") "&D2\Q3"
  14. ! ------------------------------------------
  15. ! Resetting the modem:
  16. ! ------------------------------------------
  17. @Hangup
  18.   SetTries 2
  19.   Flush
  20.   HsReset 0,0,17,19,0,0
  21. !
  22. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  23. ! to enter the command mode
  24. !
  25. @Label 1
  26.   matchclr
  27.   matchstr 1 2 "OK\r\n"
  28.   write "ATH0&F\r"
  29.   matchread 20
  30.   Write "+++"
  31.   DtrClear
  32.   pause 5
  33.   DtrSet
  34. !
  35.   SerReset 19200,0,8,1
  36.   DecTries
  37.   IfTries 1 1
  38.   SerReset 9600,0,8,1
  39.   IfTries 0 1
  40. !
  41. ! OSErr -6019 "Modem error - the modem is not responding"
  42. !
  43.   exit -6019
  44. @Label 2
  45.   write "AT+FCLASS=0\r"
  46.   Jsr 100
  47.   SerReset 9600,0,8,1
  48.   write "AT+FAA=0\r"
  49.   Jsr 100
  50.   exit 0
  51.  
  52. ! ------------------------------------------
  53. !    Receiving incoming calls
  54. ! ------------------------------------------
  55. @ANSWER
  56. !
  57. ! Set the modem preferred speed first
  58. !
  59.   SerReset 9600,0,8,1
  60.   Jsr 80
  61. @Label 10
  62. !
  63. ! Set the common options
  64.   Jsr 70
  65. !
  66. ! Set the communication options:
  67. ! • \N0:  Normal connection (for ARA)
  68. ! • W1:  report connection speed
  69. !
  70.   Write "AT\\N0W1\r"
  71.   Jsr 100
  72. !
  73. ! Set Fax parameters: LID, DCC,BOR
  74. !
  75.   Write "AT+FCLASS=2\r"
  76.   Jsr 100
  77. ! Nice feature: when in Class 2, the modem switches to 19200 always!
  78.   SetSpeed 19200
  79.   Write "AT+FLID=\"^5\"\r"
  80.   Jsr 100
  81.   Write "AT+FDCC=1,3,0,2,0,0,0,0\r"
  82.   Jsr 100
  83.   Write "AT+FBOR=1\r"
  84.   Jsr 100
  85.   Write "AT+FCR=1\r"
  86.   Jsr 100
  87. !
  88. ! Tell the modem to determine the type of the incoming call
  89. ! Fetch the tube after ^4 rings
  90. !
  91.   Write "ATS0=^4+FAA=1\r"
  92.   Jsr 100
  93. !
  94. ! Everything is ready - let's sit and wait for a call
  95. ! We'll wait for 2 minutes, then reinitiate the modem
  96. !
  97.   Note "Waiting for a fax or ARA call…"
  98. @Label 15
  99.   MatchClr
  100.   matchstr 1 16 "RING\r\n"
  101.   matchstr 2 20 "\r\nCARRIER "
  102.   matchstr 3 30 "\r\n+FCON"
  103.   matchstr 4 10 "\r\nNO "
  104.   matchstr 5 10 "\r\nBUSY"
  105.   Matchread 1200
  106.   jump 10
  107. @Label 16
  108.   Note "Ring…"
  109.   jump 15
  110. !
  111. ! Data connection has been established (we read "CARRIER")
  112. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  113. ! if it was an incoming call, put the "RING" before the "CONNECT"
  114. !
  115. @Label 20
  116.   QueueInput "\r\nCARRIER "
  117.   ifOriginate 21
  118.   QueueInput "\r\nRING\r\n"
  119. @Label 21
  120.   Attach "ARA" (DTR,Escape,TimeLimit=0)
  121. !
  122. ! Fax connection has been established (we read "+FCON")
  123. ! Put the +FCON back to the buffer,
  124. ! if it was an incoming call, put the "RING" before the "+FCON"
  125. ! Attach the "Fax" subPort
  126. !
  127. @Label 30
  128.   QueueInput "\r\n+FCON"
  129.   ifOriginate 31
  130.   QueueInput "\r\nRING\r\n"
  131. @Label 31
  132.   Attach "Fax" (DTR,Reset,Escape,IdleLimit=30)
  133.  
  134. ! ------------------------------------------
  135. ! Originating a call through the "ARA" subport
  136. ! ------------------------------------------
  137. @ORIGINATE "ARA"
  138.   SerReset 9600,0,8,1
  139.   Jsr 80
  140. !
  141. ! Set the common options
  142. !
  143.   Jsr 70
  144. !
  145. ! Set the Data mode:
  146. ! • \N0 Normal connection (no compression, correction - for ARA)
  147. ! • W1:  report connection rate
  148. !
  149.   Write "AT\\N0W1\r"
  150.   Jsr 100
  151. !
  152. ! Prepare to receive all error result codes, dial the number
  153. !
  154.   Jsr 90
  155.   HSReset 0 1 0 0 0 0
  156.   MatchStr 1 20 "\r\nCARRIER "
  157.   MatchRead 1000
  158.   Write "\r"
  159.   Exit -6019
  160.  
  161. ! ------------------------------------------
  162. ! Originating a call through the "Fax" subPort
  163. ! ------------------------------------------
  164. @ORIGINATE "Fax" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
  165. !
  166. ! Set the "Fax" speed
  167. !
  168.   SerReset 9600,0,8,1
  169.   Jsr 80
  170. !
  171. ! Set the common options
  172. !
  173.   Jsr 70
  174. !
  175. ! Set the Fax mode
  176. ! \Q1: Xon/Xoff handshake
  177. ! &S0: DSR always on (see above)
  178. !
  179.   Write "AT\\Q1&S0+FCLASS=2\r"
  180.   Jsr 100
  181.   SetSpeed 19200
  182. !
  183. ! Now emit all commands that the application has sent to that port,
  184. !
  185.   EmitClear "+FCLASS"
  186.   Jsr 60
  187. !
  188. ! Prepare to receive all error result codes, dial the number
  189. !
  190.   Jsr 90
  191.   MatchStr 1 30 "\r\n+FCON"
  192.   MatchRead 900
  193.   Write "\r"
  194.   Exit -6019
  195. !
  196. ! This section emits all modem commands sent from the client application
  197. ! For each set of commands the "OK" answer is awaited
  198. !
  199. @Label 60
  200.   EmitStart
  201. @Label 61
  202.   EmitCommand 62
  203.   Jsr 100
  204.   Jump 61
  205. @Label 62
  206.   return
  207. !
  208. ! This section initiates the modem before ANSWER and ORIGINATEs:
  209. ! extended responses + connect at the highest rate + speaker control +
  210. ! reset on Dtr drop + DCD valid
  211. ! Verbal responses mode, no echo 
  212. !
  213. @Label 70
  214.   Write "ATX4M^2L^3^6&C1V1E0\r"
  215.   Jsr 100
  216.   return 
  217.  
  218. !
  219. ! This section syncronize the modem after the serial port speed switching
  220. !
  221. @Label 80
  222.   ChrDelay 1
  223.   Write "AT\r"
  224.   ChrDelay 0
  225.   Jsr 100
  226.   return
  227. !
  228. ! Prepare to receive error result codes, send the dialing command and
  229. ! set the user's handshake mode
  230. !
  231. @Label 90
  232.   MatchClr
  233.   MatchStr 2 91 "NO DIALTONE\r\n"
  234.   MatchStr 3 92 "BUSY\r\n"
  235.   MatchStr 4 93 "NO CARRIER\r\n"
  236.   MatchStr 5 94 "NO ANSWER\r\n"
  237.   Write "ATD^1\r"
  238.   HsReset *
  239.   return
  240. @Label 91
  241.   exit -6020
  242. @Label 92
  243.   exit -6022
  244. @Label 93
  245.   exit -6021
  246. @Label 94
  247.   exit -6023
  248. !
  249. ! Processing the AT command:
  250. ! OK -> proceed
  251. ! ERROR or TimeOut ->exit -6019
  252. ! It can be called AFTER the "Write" command, since LineShare buffers input
  253. !
  254. @Label 100
  255.   MatchClr
  256.   MatchStr 1 102 "\r\nOK\r\n"
  257.   MatchStr 2 101 "\r\nERROR\r\n"
  258.   MatchRead 20
  259. @Label 101
  260.   Exit -6019
  261. @Label 102
  262.   return
  263.